package cn.wolfcode.luowowo.scenic.service.impl;


import cn.wolfcode.luowowo.common.query.PhotoQueryObject;
import cn.wolfcode.luowowo.scenic.domain.Photo;
import cn.wolfcode.luowowo.scenic.mapper.PhotoMapper;
import cn.wolfcode.luowowo.scenic.service.IPhotoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class PhotoServiceImpl implements IPhotoService {

    @Autowired
    private PhotoMapper mapper;


    public PageInfo<Photo> queryByScenicId(PhotoQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Photo> photos = mapper.selectForList(qo);
        return new PageInfo<>(photos);
    }

    @Override
    public Photo getById(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public void save(Photo photo) {
        photo.setCreatTime(new Date());
        mapper.insert(photo);
    }
}
